package edu.lsnu.equipment_management_system.controller;

import edu.lsnu.equipment_management_system.pojo.domain.JsonData;
import edu.lsnu.equipment_management_system.pojo.domain.PageBean;
import edu.lsnu.equipment_management_system.pojo.vo.out.information_list.damage.EquipmentDamageBasicVo;
import edu.lsnu.equipment_management_system.pojo.vo.out.information_list.transfer_out.EquipmentTransferOutBasicVo;
import edu.lsnu.equipment_management_system.pojo.vo.out.information_list.used_using.DeviceVo;
import edu.lsnu.equipment_management_system.service.EquipmentInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author mzywucai
 * @Description 后续加上的管理员页面的用户信息的展示
 * @date 2019/1/4
 */
@RestController
public class AdminEquipmentInformationController {
    @Autowired
    EquipmentInformationService equipmentInformationService;

    /**
     * @Description 管理员：获取所有在用的设备的简略信息列表
     * @author mzy
     * @time 2018-11-24
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/getUsingEquipmentBasicInformation/{pageNum}")
    public Object getAdminUsingEquipmentBasicInformationVo(@PathVariable Integer pageNum) {
        PageBean<DeviceVo> adminUsingEquipmentBasicInformationVo =
                equipmentInformationService.getAdminUsingEquipmentBasicInformationVo(pageNum);

        if (null == adminUsingEquipmentBasicInformationVo) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminUsingEquipmentBasicInformationVo, "操作成功");
        }
    }

    /**
     * @Description 管理员：获取所有报损报废设备的简略信息列表
     * @author mzy
     * @time 2018-11-24
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/getDamageEquipmentBasicInformation/{pageNum}")
    public Object getAdminDamageEquipmentBasicInformationVo(@PathVariable Integer pageNum, HttpSession session) {
        PageBean<EquipmentDamageBasicVo> adminDamageEquipmentBasicInformationVo =
                equipmentInformationService.getAdminDamageEquipmentBasicInformationVo(pageNum);

        if (null == adminDamageEquipmentBasicInformationVo) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminDamageEquipmentBasicInformationVo, "操作成功");
        }
    }

    /**
     * @Description 管理员：获取所有调出设备的简略信息列表
     * @author mzy
     * @time 2018-11-24
     * @see
     * @return   java.lang.Object
     * @params  []
     */
    @GetMapping("/api/admin/getTransferOutEquipmentBasicInformation/{pageNum}")
    public Object getAdminTransferOutEquipmentBasicInformationVo(@PathVariable Integer pageNum) {
        PageBean<EquipmentTransferOutBasicVo> adminTransferOutEquipmentBasicInformationVo =
                equipmentInformationService.getAdminTransferOutEquipmentBasicInformationVo(pageNum);

        if (null == adminTransferOutEquipmentBasicInformationVo) {
            return JsonData.buildError("操作失败");
        } else {
            return JsonData.buildSuccess(0, adminTransferOutEquipmentBasicInformationVo, "操作成功");
        }
    }

}
